package com.example.studentgrades.service;

import com.example.studentgrades.entity.Grade;
import com.example.studentgrades.repository.GradeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class GradeService {
    @Autowired
    private GradeRepository gradeRepository;

    public List<Grade> findAll() {
        return gradeRepository.findAll();
    }

    public List<Grade> findByCourseId(Integer courseId) {
        return gradeRepository.findByCourseId(courseId);
    }

    public void save(Grade grade) {
        gradeRepository.save(grade);
    }

    public List<Grade> findByScoreRange(BigDecimal minScore, BigDecimal maxScore) {
        return gradeRepository.findByScoreBetween(minScore, maxScore);
    }
}
